package org.testmyapp.persistence;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class PersistenceCommons {

	// By convention every entity class must have a static String field
	// containing its table name
	public static String fieldTableName = "tableName";

	public static String getTableName(Class classObject) {
		Field[] declaredFields = classObject.getDeclaredFields();
		String tableName = null;
		for (Field field : declaredFields) {
			if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
				String fieldName = field.getName();
				if (fieldName.equals(fieldTableName)) {
					tableName = fieldName;
				}
			}
		}
		if (tableName == null) {

		}
		return tableName;
	}

}
